package com.demo.bigdata

import org.apache.spark.{SparkConf, SparkContext}

object ReduceAndGroupByKey {
  def main(args: Array[String]): Unit = {
    val conf = (new SparkConf).setMaster("local").setAppName("Demo");
    val sc = new SparkContext(conf)
    val lines = sc.parallelize(List("Hadoop","Hive","Hbase","Spark","Hadoop","Hive"))
    val map = lines.map(r=>(r,1))
    map.foreach(println(_))
    val reduceByKey = map.reduceByKey(_+_)
    reduceByKey.foreach(println(_))
    val groupByKey = map.groupByKey()
    groupByKey.foreach(println(_))
  }
}
